﻿using System;
using System.Collections.Generic;
using System.Text;
using FDSimpleModelGenerator.DapperAccessor;
using FDSimpleModelGenerator.IServices;
using Microsoft.Extensions.DependencyInjection;

namespace FDSimpleModelGenerator.Repositories
{
    /// <summary>
    /// 使用基础仓储
    /// </summary>
    public static class RepositoryUsing
    {
        /// <summary>
        /// 仓储基本依赖
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection UsingRepositories(this IServiceCollection services)
        {
            services.Remove(new ServiceDescriptor(typeof(IDbAccessor), typeof(DapperDbAccessor),
                ServiceLifetime.Transient));
            services.AddTransient<IDbAccessor, DapperDbAccessor>();

            return services;
        }
    }
}
